window._STATUSCOLORCONF = {
	
	'增益':{word:'#47d6ff',nmb:'#0092BC'},
	'减益':{word:'#ff0000',nmb:'#DC143C'},
	'毒':{word:'#00be04',nmb:'#2E8B57'},
	'武':{word:'#fff000',nmb:'#DAA520'},
};


window._STATUSCONF = {
				
		//攻击增益
		'a1':{attr:'attack',flag:true,name:'攻',label:'增益'},
		
		//攻击减益
		'a2':{attr:'attack',flag:false,name:'攻',label:'减益'},

		//防御增益
		'd1':{attr:'defend',flag:true,name:'防',label:'增益'},
	
		//防御减益
		'd2':{attr:'defend',flag:false,name:'防',label:'减益'},
		
		//精神增益
		'i1':{attr:'mattack',flag:true,name:'精',label:'增益'},
		
		//精神减益
		'i2':{attr:'mattack',flag:false,name:'精',label:'减益'},
		
		//魔抗增益
		'mk1':{attr:'mdefend',flag:true,name:'魔',label:'增益'},
		
		//魔抗减益
		'mk2':{attr:'mdefend',flag:false,name:'魔',label:'减益'},
		
		//命中增益
		'mz1':{attr:'hit',flag:true,name:'命',label:'增益'},
		
		//命中减益
		'mz2':{attr:'hit',flag:false,name:'命',label:'减益'},
		
		//速度增益
		's1':{attr:'speed',flag:true,name:'速',label:'增益'},
		
		//速度减益
		's2':{attr:'speed',flag:false,name:'速',label:'减益'},
		
		//闪避增益
		'm1':{attr:'miss',flag:true,name:'闪',label:'增益'},
		
		//闪避减益
		'm2':{attr:'miss',flag:false,name:'闪',label:'减益'},
		
		//晕眩
		'h1':{attr:'yunxuan',flag:false,name:'晕',label:'武',isyx:1},
		
		'h2':{attr:'yunxuan',flag:false,name:'晕',notLive:1},
		
		//中毒
		'zd':{attr:'zd',flag:false,name:'毒',label:'毒',iszd:1},
		
		'zd2':{attr:'zd',flag:false,name:'毒',notLive:1},
		
		//盾
		'dun':{attr:'dun',flag:true,name:'盾',label:'武',forever:1},
		
		//挡
		'dang':{attr:'dang',flag:true,name:'挡',label:'武',isdang:1,forever:1},

		//禁 禁止回血
		'jinliao':{attr:'jinliao',flag:false,name:'禁',isjinliao:1,label:'减益'},
		//冻 无法恢复能量 无敌 受到伤害时候解除
		'bindong':{attr:'bindong',flag:false,name:'冻',isbingdong:1,label:'减益'},
		//困 无法逃跑
		'kunbang':{attr:'kunbang',flag:false,name:'困',iskunbang:1,label:'减益'},
	}

window.RSH = {

	hasAttr:function(statusArr,attr){

		if(!statusArr){
			return false;
		}

		for(var i=0;i<statusArr.length;i++){
			
			var tmpstatusname = statusArr[i].name;
			
			if(_STATUSCONF[tmpstatusname][attr]){
				return true;
			}
			
		}
		
		return false;

	},

	hasbindong:function(statusArr){

		return RSH.hasAttr(statusArr,'isbingdong');
		
	},

	hasjinliao:function(statusArr){

		return RSH.hasAttr(statusArr,'isjinliao');
		
	},

	haskunbang:function(statusArr){

		return RSH.hasAttr(statusArr,'iskunbang');
		
	},

	hasdang:function(statusArr){
		
		return RSH.hasAttr(statusArr,'isdang');
		
	},
	
	hasHun:function(statusArr){
		
		return RSH.hasAttr(statusArr,'isyx');
		
	},

	hasDu:function(statusArr){
		
		return RSH.hasAttr(statusArr,'iszd');
		
	},
	
	reduceAttr:function(statusArr,attr,nmb){
		
		if(statusArr){
			for(var i=0;i<statusArr.length;i++){
				
				var tmpstatusname = statusArr[i].name;
				
				if(_STATUSCONF[tmpstatusname].attr==attr){

					if(statusArr[i].nmb-nmb>0){
						statusArr[i].nmb-=nmb;
					}else{
						statusArr.splice(i,1);
					}

					return true;
				}
				
			}
		}
		return false;
		
	},
	
	//状态消减 非永久buff 每次行动结束后回合数减1
	statusReduce:function(statusArr){
		
		for(var i=0;i<statusArr.length;){

			var tempstatus = statusArr[i];

			if(!_STATUSCONF[tempstatus.name].forever){

				if(tempstatus.nmb>1){
					tempstatus.nmb--;
					i++;
				}else{
					statusArr.splice(i,1);
				}

			}else{
				i++;
			}

		}
		
	},
	
	
	checkStatusName:function(statusName){
		
		//判断参数是否存在
		if(!statusName){
			return ;
		}
		
		//判断格式是否正确
		var statusNameArr = statusName.split("_");
		
		if(statusNameArr.length!=2){
			return null;
		}else{
			return [statusNameArr[0],statusNameArr[1]];
		}
	},
	
	
	//附加状态
	//同类型状态覆盖原来回合数
	//相斥类型状态移除状态
	addRealStatus:function(statusArr,statusName){
		
		//判断参数是否存在
		if(!statusArr){
			return ;
		}

		var statusNameArr = RSH.checkStatusName(statusName);

		if(!statusNameArr){
			return ;
		}
		
		var realName = statusNameArr[0];
		var realNmb = statusNameArr[1]/1;
		
		var statusObj = _STATUSCONF[realName];
		
		//判断状态是否存在
		if(!statusObj){
			return ;
		}
		
		//遍历已经存在的状态 如果有attr相同 则进行叠加计算
		for(var i=0;i<statusArr.length;i++){
			
			var tmpstatus = statusArr[i];
			
			if(tmpstatus&&tmpstatus.name&&_STATUSCONF[tmpstatus.name]){
				
				var oldstatus = _STATUSCONF[tmpstatus.name];
				
				if(oldstatus.attr == statusObj.attr){
					
					if(oldstatus.flag==statusObj.flag){
						
						tmpstatus.nmb=realNmb;
						
					}else{
						
						statusArr.splice(i,1);
						
					}
					
					return ;
					
				}
				
			}
			
		}

		if(!statusObj.notLive)
			statusArr.push({name:realName,nmb:realNmb});
		
	},
	
}